{{template "/head.tpl" .}}
<style>
    .container{
        position: relative;
        min-width:340px;
        max-width: 340px;
        height: 195px;
        margin-top: 15rem;
        border: 1px solid #FFFFFF;
        background-color: #FFFFFF;
        margin-top: 2rem;
        border-radius: 12px;
        padding-top: 12px;
        opacity: 0.8;
    }
    .form-control{
        background-color: #BEE691;
        /*color: #FFFFFF;*/
    }
    input,button,a {
        outline:0 none !important; blr:expression(this.onFocus=this.blur());
    }
</style>
<body style="background-color: #15435D;color: #FFFFFF;">
<div style="margin-top: 15rem;">
    <div>
        <h2 class="form-signin-heading" align="center">Docker私有云平台</h2>
    </div>
    <div class="container">
        <form class="form-horizontal">
            {{._token}}
            <div class="form-group accout">
                <label for="inputEmail3" for="account" class="col-sm-1 control-label"></label>
                <div class="col-sm-12">
                    <input type="text" class="form-control" id="account" placeholder="账户" required>
                </div>
            </div>
            <div class="form-group passwd">
                <label for="inputEmail3" for="password" class="col-sm- control-label"></label>
                <div class="col-sm-12">
                    <input  type="password" class="form-control" id="password" placeholder="密码" required>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-4" style="margin-left:23%;">
                    <button type="button" class="btn btn-lg btn-block butt" style="border-radius: 14px;height: 44px;width: 162px;margin-top: 10px;background-color:#15435D;">登录</button>
                </div>
            </div>
        </form>
    </div>
</div>
</body>
<script>
    $(".butt").bind('click',function () {
        var account = $('#account').val();
        var passwd = $('#password').val();
        var xsrf, xsrflist;
        xsrf = $.cookie("_xsrf");
        xsrflist = xsrf.split("|");
        _xsrf = Base64.decode(xsrflist[0]);
        if (account==''){
            $('.accout').addClass('has-error');
            showMsg('请填写账户');
            return false;
        }

        if (passwd==''){
            $('.passwd').addClass('has-error');
            showMsg('请填写密码');
            return false;
        }

        $('.passwd').removeClass('has-error');
        $('.accout').removeClass('has-error');
        $('.passwd').addClass('has-success');
        $('.accout').addClass('has-success');
        $.ajax({
           url:'/login',
           type:"POST",
           dataType:"json",
           data:{account:account,password:passwd,_xsrf:_xsrf},
           success:function (res) {
               console.log(res);
               if (res.code==200){
                   showMsg(res.message,true);
               } else{
                   showMsg(res.message);
               }
           },
            error:function (xhr) {
               console.dir(xhr);
                showMsg(xhr.responseText);
            }
        });
       return false;
    });
</script>
{{template "/footer.tpl" .}}